package screens 
{
	import flash.display.MovieClip;
	import flash.display.Sprite;
	import flash.events.KeyboardEvent;
	import flash.events.MouseEvent;
	import flash.geom.Rectangle;
	/**
	 * ...
	 * @author Andy Wolff
	 */
	public class ScaleScreen extends Screen
	{
		private var main:Main;
		
		private	var panel:MovieClip = new MovieClip();
		private	var windBtn:MovieClip = new MovieClip();
		private	var brassBtn:MovieClip = new MovieClip();
		private	var fluteBtn:MovieClip = new MovieClip();
		private	var oboeBtn:MovieClip = new MovieClip();
		private	var trumpetBtn:MovieClip = new MovieClip();
		private	var selectLine:MovieClip = new MovieClip();
		private	var selectLine2:MovieClip = new MovieClip();
		
		
		[Embed(source = '../images/Buttons/songmaker.png')] private var spacerimg:Class;
		
		[Embed(source = '../images/newsong.png')] private var newsongimg:Class;
		[Embed(source = '../images/Buttons/Scale.png')] private var titleimg:Class;
		[Embed(source = '../images/Buttons/back.png')] private var backimg:Class;
		[Embed(source = '../images/Buttons/continue.png')] private var continueimg:Class;
		
		[Embed(source = '../images/Buttons/scaleInfo.png')] private var scaleInfoimg:Class;
		public function ScaleScreen(main:Main) 
		{
			this.main = main;
			super();
			graphics.beginFill(0x555555, 1);
			graphics.drawRect(0, 0, 800, 470);
			graphics.endFill();
			main.stage.addEventListener(KeyboardEvent.KEY_DOWN, this.keypressed);
			
			
			//Used for spacing buttons consistently across screens
			var spacer:MovieClip = new MovieClip();
			spacer.addChild(new spacerimg())
			Main.center(spacer);
			spacer.y = 20;
			
			//Title of the screen
			var title:MovieClip = new MovieClip();
			title.addChild(new titleimg())
			Main.center(title);
			title.y = 20;
			addChild(title);
			
			//Static scale info image
			panel.addChild(new scaleInfoimg())
			Main.center(panel);
			addChild(panel);
			
			//Back button
			var backBtn:MovieClip = new MovieClip();
			backBtn.addChild(new backimg());
			Main.center(backBtn);
			backBtn.y = spacer.y + spacer.height + 280;
			backBtn.x -= 225;
			addChild(backBtn);
			backBtn.addEventListener(MouseEvent.CLICK, click_back);
			
			//Continue button
			var continueBtn:MovieClip = new MovieClip();
			continueBtn.addChild(new continueimg());
			Main.center(continueBtn);
			continueBtn.y = backBtn.y;
			continueBtn.x = backBtn.x + 400;
			addChild(continueBtn);
			continueBtn.addEventListener(MouseEvent.CLICK, click_continue);
			
		}
		
		
		public function keypressed(e:KeyboardEvent):void {
			//press enter (for keycodes, see: http://www.dakmm.com/?p=272 )
			if (e.charCode==13) main.switchScreen(new MainScreen(main));
		}
		
		public function click_wind(me:MouseEvent):void {
			
			selectLine.y = windBtn.y;
			
			Main.center(oboeBtn);
			oboeBtn.x += 160;
			oboeBtn.y -= 100;
			
			
			fluteBtn.x = oboeBtn.x;
			fluteBtn.y = oboeBtn.y + oboeBtn.height + 10;
			
			
			trumpetBtn.x = 10000;
			
			
		}
		
		
		public function click_brass(me:MouseEvent):void {
			
			selectLine.y = windBtn.y + windBtn.height + 10;
			
			selectLine2.y = windBtn.y;
			
			oboeBtn.x = 10000;
			fluteBtn.x = 10000;
			
			Main.center(trumpetBtn);
			trumpetBtn.x += 130;
			trumpetBtn.y -= 95;
			
		}
		
		
		public function click_flute(me:MouseEvent):void {
			
			selectLine2.y = fluteBtn.y;
		}
		
		
		public function click_oboe(me:MouseEvent):void {
			
			selectLine2.y = windBtn.y;
			
		}
		
		public function click_back(me:MouseEvent):void {
			main.switchScreen(new InstrumentScreen(main));
		}
		
		public function click_continue(me:MouseEvent):void {
			main.switchScreen(new MainScreen(main));
		}
		
		
		
		override public function end():void 
		{
			main.stage.removeEventListener(KeyboardEvent.KEY_DOWN, this.keypressed);
		}
		
	}

}